// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuebar from 'vuebar'
import 'normalize.css/normalize.css'
import 'nprogress/nprogress.css'
import '@/assets/styles/index.less'
// import '@/assets/styles/element-ui.less'
import App from './App'
import '@/assets/iconfont-default'
import '@/assets/iconfont'
import router from './router/'
import store from './store/'
import _ from 'lodash'
import '@/components'
import ElementUI from 'element-ui'
import Egrid from 'egrid'
import moment from 'moment'
import fileServer from '@api/config'
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/icon.css'
import 'element-ui/lib/theme-chalk/table.css'
import 'element-ui/lib/theme-chalk/table-column.css'

import {
  transStatus,
  transUser,
  transSex,
  transIs,
  transType,
  sexTrans,
  transSexUnknow
} from '@tools'
let fs = require('fs')
console.log(router)
Vue.use(Egrid)
Vue.use(ElementUI)
Vue.use(Vuebar)
Vue.prototype.$transStatus = transStatus
Vue.prototype.$transSexUnknow = transSexUnknow
Vue.prototype.$lodash = _
Vue.prototype.$moment = moment
Vue.prototype.$transType = transType
Vue.prototype.$fileServer = fileServer
Vue.prototype.$transUser = transUser
Vue.prototype.$transSex = transSex
Vue.prototype.$transIs = transIs
Vue.prototype.$sexTrans = sexTrans
Vue.config.productionTip = false

const findPercent = (str) => {
  if (!str) return true
  if (str.indexOf('%') > -1) return false
  return true
}
Vue.directive('intercept', {
  update (el, binding, vnode) {
    console.dir(el, binding, vnode)
    let flag = findPercent(binding.value)
    if (!flag) {
      ElementUI.Message.warning('输入%将影响搜索结果')
    }
  }
})
/* eslint-disable no-new */
console.log(JSON.stringify(router.options))
fs.writeFile('./src/api/haha.js', JSON.stringify(router.options), function (err) {
  if (err) {
    console.log(err)
  }
})
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
